/*****************************************************************************
Copyright 2006 Kervin L. Pierre
    EMAIL: otlkcon@adevsoft.com

This file is part of Otlkcon.

Otlkcon is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

Otlkcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lesser GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License
along with Otlkcon; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*******************************************************************************/

#pragma once

//#define OTLKCON_ENTERCRITICALSECTION(x,y)    EnterCriticalSection(x)
//#define OTLKCON_LEAVECRITICALSECTION(x,y)    LeaveCriticalSection(x)
//just for test
#include <windows.h>

class CSWrapper
{
public:
	CSWrapper(LPCRITICAL_SECTION lpSection)
	{
		m_lpSection = lpSection;
		EnterCriticalSection(m_lpSection);
	}
	~CSWrapper()
	{
		LeaveCriticalSection(m_lpSection);
	}
protected:
	LPCRITICAL_SECTION m_lpSection;
};
#define OTLKCON_ENTERCRITICALSECTION_INT2(x,y) CSWrapper sect##y(x)
#define OTLKCON_ENTERCRITICALSECTION_INT(x,y) OTLKCON_ENTERCRITICALSECTION_INT2(x,y)
#define OTLKCON_ENTERCRITICALSECTION(x,y) OTLKCON_ENTERCRITICALSECTION_INT(x,__COUNTER__)
#define OTLKCON_LEAVECRITICALSECTION(x,y)

//#define OTLKCON_LEAVECRITICALSECTION(x,y) otlkcon_leaveCriticalSection( x, y  )
//#define OTLKCON_ENTERCRITICALSECTION(x,y) otlkcon_enterCriticalSection( x, y  )
